import Vue from 'vue';
import vuex from 'vuex'

Vue.use(vuex);

export default new vuex.Store({
    state: {
        isCollapse: false,
        MenuList: [{
                id: '1',
                name: '组织架构',
                icon: 'el-icon-user-solid',
                children: [{
                        name: '部门管理',
                        path: '/Organizational/DepartmentManage'
                    },
                    {
                        name: '岗位管理',
                        path: '/Organizational/PostManage'
                    },
                    {
                        name: '角色管理',
                        path: '/Organizational/RoleManage'
                    },
                    {
                        name: '用户管理',
                        path: '/Organizational/UserManage'
                    }
                ]
            },
            {
                id: '2',
                name: '主数据',
                icon: 'el-icon-user-solid',
                children: [{
                        name: '编码规则',
                        path: '/MasterData/CodingRules'
                    },
                    {
                        name: '物料产品管理',
                        path: '/MasterData/MaterialProductsManage'
                    },
                    {
                        name: '物料产品分类',
                        path: '/MasterData/MaterialsProductClassify'
                    },
                    {
                        name: '计量单位',
                        path: '/MasterData/MeasurementUnit'
                    },
                    {
                        name: '客户管理',
                        path: '/MasterData/CustomerManage'
                    },
                    {
                        name: '供应商管理',
                        path: '/MasterData/SupplierManage'
                    },
                    {
                        name: '车间设置',
                        path: '/MasterData/WorkshopSet'
                    },
                    {
                        name: '工作站',
                        path: '/MasterData/Workstation'
                    }
                ]
            },
            {
                id: '3',
                name: '生产管理',
                icon: 'el-icon-user-solid',
                children: [{
                        name: '生产计划',
                        path: '/Producetion/ProductionPlan'
                    },
                    {
                        name: '工序设计',
                        path: '/Producetion/ProcessDesign'
                    },
                    {
                        name: '工艺流程',
                        path: '/Producetion/Technology'
                    },
                    {
                        name: '生产排产',
                        path: '/Producetion/ProductionScheduling'
                    },
                    {
                        name: '生产报工',
                        path: '/Producetion/ProductionReporting'
                    }
                ]
            }, {
                id: '4',
                name: '质量管理',
                icon: 'el-icon-user-solid',
                children: [{
                        name: '常见缺陷',
                        path: '/QualityManage/Defect'
                    },
                    {
                        name: '检测项设置',
                        path: '/QualityManage/DetectionSettings'
                    },
                    {
                        name: '检测模板',
                        path: '/QualityManage/DetectionTemplate'
                    },
                    {
                        name: '来料检验',
                        path: '/QualityManage/Incoming'
                    },
                    {
                        name: '过程检验',
                        path: '/QualityManage/Process'
                    },
                    {
                        name: '出货检验',
                        path: '/QualityManage/Shipping'
                    }
                ]
            },
            {
                id: '5',
                name: '库存管理',
                icon: 'el-icon-user-solid',
                children: [{
                        name: '仓库设置',
                        path: '/Inventory/WarehouseSettings'
                    },
                    {
                        name: '库区设置',
                        path: '/Inventory/Reservoir'
                    },
                    {
                        name: '仓库现有量',
                        path: '/Inventory/WarehouseInventory'
                    },
                    {
                        name: '采购入库',
                        path: '/Inventory/PurchaseReceipt'
                    },
                    {
                        name: '供应商退货',
                        path: '/Inventory/SupplierReturn'
                    },
                    {
                        name: '生产领料',
                        path: '/Inventory/ProductionMaterialRequisition'
                    },
                    {
                        name: '生产退料',
                        path: '/Inventory/ProductionReturn'
                    },
                    {
                        name: '产品入库',
                        path: '/Inventory/ProductStorage'
                    },
                    {
                        name: '销售出库',
                        path: '/Inventory/SalesOutbound'
                    },
                    {
                        name: '转移调拨',
                        path: '/Inventory/Transfertransfer'
                    },
                    {
                        name: '销售退货',
                        path: '/Inventory/SalesReturn'
                    },
                    {
                        name: '赋码管理',
                        path: '/Inventory/CodeAssignmentManagement'
                    },
                    {
                        name: '装箱管理',
                        path: '/Inventory/PackingManagement'
                    },
                    {
                        name: 'SN码',
                        path: '/Inventory/SNCode'
                    }
                ]
            },
            {
                id: '6',
                name: '设备管理',
                icon: 'el-icon-user-solid',
                children: [{
                        name: '设备类型设置',
                        path: '/Equipment/DeviceType'
                    },
                    {
                        name: '设备台账',
                        path: '/Equipment/Equipmentledger'
                    },
                    {
                        name: '点检保养项目',
                        path: '/Equipment/InspectionItems'
                    },
                    {
                        name: '点检保养计划',
                        path: '/Equipment/InspectionPlan'
                    },
                    {
                        name: '维修单',
                        path: '/Equipment/RepairOrder'
                    }
                ]
            },
            {
                id: '7',
                name: '模具管理',
                icon: 'el-icon-user-solid',
                children: [{
                        name: '类型设置',
                        path: '/MoldManage/TypeSet'
                    },
                    {
                        name: '工装夹具台账',
                        path: '/MoldManage/FixtureLedger'
                    }
                ]
            }

        ],
        breadcrumb: [],
        tagNavMenu: [{ type: 'success', effect: 'dark' /*plain*/ , label: '首页', path: '/Console' }]
    },
    mutations: {
        toggle(state) {
            state.isCollapse = !state.isCollapse;
        },
        getindexbreadcrumbs(state, e) {
            state.breadcrumb = [];
            e.forEach(x => {
                if (x.path != "") {
                    state.breadcrumb.push(x);
                }
            })

        },
        getnavmenu(state, e) {
            state.tagNavMenu.forEach((item) => {
                if (item.label !== e.name) {
                    item.effect = "plain"
                } else {
                    item.effect = "dark"
                }
            })
            if (state.tagNavMenu.findIndex(x => (x.label === e.name)) == -1) {
                state.tagNavMenu.push({ type: 'success', effect: 'dark' /*plain*/ , label: e.name, path: e.path });
            }
        }

    }
})